//新增会员的store

import axios from 'axios'
import http from '../../../http/http'
import * as URL from '../../../http/api'

const state = {

};

const actions = {
    //查看会员名重复
    isTureMemberName({commit},obj){
        let newMemberName={};
        newMemberName.name=obj.memberName;
        // console.log(newMemberName);
        return http({
            url:URL.memberName,
            method:'post',
            data:newMemberName,
        }).then(res=>{
            // console.log(res);
            return res.data;
        });
    },

    //提交新增会员
    addMember({commit},obj){
        let newMemberInfo = {name:'',password:'',sex:undefined,tel:'',idCard:''};
        newMemberInfo.name = obj.memberName;
        newMemberInfo.password = obj.memberPassword;
        newMemberInfo.sex = parseInt(obj.memberSex.replace('男','1').replace('女','2'));
        newMemberInfo.tel = obj.memberTel;
        newMemberInfo.idCard = obj.memberIDCard;
        // console.log(newMemberInfo);
        return http({
            url:URL.memberRegist,
            method:'post',
            data:newMemberInfo,
        }).then(res=>{
            // console.log(res);
            return res.data;
        });
    }

};

const mutations = {

};

export default{
    state,
    actions,
    mutations
}